package com.xgk.boot.module.core.dal.mapper.truck;

import com.xgk.boot.framework.common.pojo.PageResult;
import com.xgk.boot.framework.mybatis.core.mapper.BaseMapperX;
import com.xgk.boot.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.xgk.boot.module.core.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
import com.xgk.boot.module.core.controller.admin.truck.vo.ApiLogPageReqVO;
import com.xgk.boot.module.core.dal.entity.truck.TruckOrderApiLogDO;
import org.apache.ibatis.annotations.Mapper;

import java.time.Instant;
import java.time.LocalDateTime;

/**
 * 订单API请求日志 Mapper接口
 */
@Mapper
public interface TruckOrderApiLogMapper extends BaseMapperX<TruckOrderApiLogDO> {

    default PageResult<TruckOrderApiLogDO> selectPage(ApiLogPageReqVO pageReqDTO) {
        return selectPage(pageReqDTO, new LambdaQueryWrapperX<TruckOrderApiLogDO>()
                .eqIfPresent(TruckOrderApiLogDO::getCreator, pageReqDTO.getUserId())
                .eqIfPresent(TruckOrderApiLogDO::getOrderCode, pageReqDTO.getOrderCode())
                .eqIfPresent(TruckOrderApiLogDO::getReferenceNo, pageReqDTO.getReferenceNo())
                .betweenIfPresent(TruckOrderApiLogDO::getCreateTime,new Instant[]{pageReqDTO.getStartTime(),pageReqDTO.getEndTime()})
                .orderByDesc(TruckOrderApiLogDO::getCreateTime));
    }
}